﻿using System;
using FireStarterModeller.BO;
using Habanero.BO.ClassDefinition;
using Habanero.Testability;

namespace FireStarterModeller.Test.BO
{
    public class TestUtilsUITab
    {
        public static BOTestFactory<UITab> GetFactory()
        {
            return BOTestFactoryRegistry.Instance.Resolve<UITab>();
        }
        /// <summary>
        /// Creates a new saved UITab with a random value assigned to every property
        /// </summary>
        public static UITab CreateSavedUITab()
        {
            UITab uITab = CreateUnsavedValidUITab();
            uITab.Save();
            return uITab;
        }

        /// <summary>
        /// Creates a new unsaved UITab with a random value assigned to every property
        /// </summary>
        public static UITab CreateUnsavedValidUITab()
        {
/*            UITab uITab = new UITab();
            uITab.Name = TestUtilsShared.GetRandomString();
            uITab.Generated = TestUtilsShared.GetRandomBoolean();
            uITab.UIFormID = TestUtilsShared.CreateSavedUIFormInfo().UIFormID;*/
            return GetFactory().CreateValidBusinessObject();;
        }
	    
        /// <summary>
        /// Creates a new unsaved UITab where all properties are null, except ID properties
        /// and those with default values.  If there are compulsory properties without
        /// defaults, saving the object will throw an exception.
        /// </summary>
        public static UITab CreateUnsavedDefaultUITab()
        {
            UITab uITab = new UITab();
            return uITab;
        }
    }
    // ReSharper disable UnusedMember.Global
    public class UITabTestFactory:BOTestFactory<UITab>
    {
        public UITabTestFactory()
        {
            RegisterValueGeneratorForOrdinalPos();
        }

        public UITabTestFactory(UITab bo)
            : base(bo)
        {
            RegisterValueGeneratorForOrdinalPos();
        }

        private void RegisterValueGeneratorForOrdinalPos()
        {
            var classDef = ClassDef.Get<UITab>();
            var propDef = classDef.GetPropDef("OrdinalPosition");
            _validValueGenRegistry.Register(propDef, typeof(ValidValueGeneratorIncrementalInt));
        }
    }
    // ReSharper restore UnusedMember.Global
}